home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Fax Class2&ARA&Data < prev    next >
Text File  |  1995-10-25  |  9KB  |  453 lines

  1. ! Version 3.1.3
  2. !
  3. !$ Use this script with Class 2 fax software, ARA 1.0 or 2.0,
  4. !$ and a BBS, E-mail or other communication server software
  5. !
  6. !$ A cable for hardware handshaking is required
  7.  
  8. ^# Modem:
  9. ^2 Fax Software: = Enum("FaxSTFェ"="0","4-Sightェ"="1","Delrina"="2","Glenwarne sw/hsk"="3","Glenwarne hw/hsk"="4","MaxFax"="5","CommuniGate"="6") "0"
  10. ^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
  11. ^4 Handshake wires: = Bool("CTS+DTR"="&D0","CTS only"="&D2") "&D2"
  12. ^5 Answer On: = Enum("Never"="0","1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  13. ^6 Data Port Speed: = Enum("9600","19200","38400","57600") "19200"
  14. ! ------------------------------------------
  15. ! Resetting the modem:
  16. ! ------------------------------------------
  17. @Hangup
  18.   SetTries 2
  19.   Flush
  20.   HsReset 0,0,0,0,0,0
  21.   DtrSet
  22. !
  23. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  24. ! to enter the command mode
  25. !
  26. @Label 1
  27.   matchclr
  28.   matchstr 1 2 "OK¥r¥n"
  29.   write "ATH0V1Q0¥r"
  30.   matchread 20
  31.   ChrDelay 1
  32.   Write "+++"
  33.   ChrDelay 0
  34.   DtrClear
  35.   SBreak
  36.   DtrSet
  37. !
  38.   DecTries
  39.   IfTries 0 1
  40. !
  41. ! OSErr -6019 "Modem error - the modem is not responding"
  42. !
  43.   exit -6019
  44. @Label 2
  45.   SetVar A "&F"
  46.   GetOption A "DFLT" 3
  47. @Label 3
  48.   write "AT^A+FCLASS=0¥r"
  49.   Jsr 100
  50.   exit 0
  51.  
  52. @Label 6
  53.   Say "This script cannot be used with this modem"
  54.   ifOriginate 7
  55.   pause 1800
  56. @Label 7
  57.   exit -6019
  58. ! ------------------------------------------
  59. !    Receiving incoming calls
  60. ! ------------------------------------------
  61. @ANSWER
  62. @Label 10
  63. !
  64. ! Set the modem preferred speed first
  65.   SerReset Val("^6"),0,8,1
  66.   Jsr 80
  67. !
  68. ! Set the common options
  69.   Jsr 70
  70. !
  71. ! Set the communication options:
  72. ! ・ Normal/AUTO Connection
  73. ! ・ HW flow control  (for ARA, Fax should not use a handshake on receiving)
  74. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  75. !
  76.   GetOption A "HWHS" 6
  77.   GetOption B "^3" 6
  78.   GetOption C "LNRS" 6
  79.   Write "AT^A^B^C¥r"
  80.   Jsr 100
  81. !
  82. ! Set Fax parameters: LID, DCC,BOR
  83. !
  84.   Write "AT+FCLASS=2;+FCR=1;+FAA=1¥r"
  85.   Jsr 100
  86. !
  87. ! Set FLID - sometimes it can fail
  88. !
  89.   GetCommand A "Fax" "+FLID"
  90.   Write "AT^A¥r"
  91.   Jsr 120
  92. !
  93.   Write "AT+FDCC=1,3,0,2,0,0,0,0¥r"
  94.   Jsr 100
  95. !
  96. ! Set FDCC - sometimes it can fail
  97. !
  98.   GetCommand A "Fax" "+FDCC"
  99.   Write "AT^A¥r"
  100.   Jsr 120
  101. !
  102.   GetCommand A "Fax" "+FBOR"
  103.   Write "AT^A¥r"
  104.   Jsr 100
  105. !
  106. ! It's for Rockwell ONLY! Set FCLASS to 0 again
  107.   GetOption A "RCWL" 12
  108.   Write "AT+FCLASS=0¥r"
  109.   Jsr 100
  110. !
  111. @Label 12
  112. !
  113. ! Get the Speaker options
  114. !
  115.   GetCommand B "Fax" "M"
  116.   GetCommand C "Fax" "L"
  117.   SetVar A "S0=^5"
  118. !
  119. ! Answer call after <A> rings
  120. !
  121.   Write "AT^A^B^C¥r"
  122.   Jsr 100
  123. !
  124. ! Everything is ready - let's sit and wait for a call
  125. ! We'll wait for 2 minutes, then reinitiate the modem
  126.   Note "Waiting for a Fax/ARA/Data callノ"
  127.   Jsr 90
  128.   IfStr D 40 "FAX"
  129.   IfStr D 20 "DATA"
  130.   Jump 10
  131.  
  132. !
  133. ! Data connection has been established (we read "CONNECT")
  134. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  135. ! if it was an incoming call, put the "RING" before the "CONNECT"
  136. !
  137. @Label 20
  138.   IfOpen "Data" 21
  139.   Jump 30
  140. @Label 21
  141.   IfOpen "ARA" 22
  142.   Jump 35
  143. @Label 22
  144.   Note "Waiting for an ARA frame"
  145.   MatchClr
  146.   MatchStr 1 23 "^$¥r"
  147.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  148.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  149.   MatchRead 40
  150.   Jump 24
  151. @Label 23
  152.   QueueInput "^$¥r"
  153. @Label 24
  154.   Note "Non-ARA call"
  155.   Jump 35
  156.  
  157. @Label 28
  158.   Note "ARA 1.0 call"
  159.   Jump 30
  160. @Label 29
  161.   Note "ARA 2.0 call"
  162.   Jump 30
  163.  
  164. @Label 30
  165.   QueueInput "¥r¥nCARRIER ^B¥r¥n"  
  166.   IfStr A 31 "NONE"
  167.   IfStr A 31 "None"
  168.   QueueInput "¥r¥nREL¥r¥n"
  169. @Label 31
  170.   IfOriginate 32
  171.   QueueInput "¥r¥nRING¥r¥n"
  172. @Label 32
  173.   Attach "ARA" (DTR)
  174.  
  175. @Label 35
  176.   GetSReg C "DATA" 4
  177.   QueueInput "¥r^CCONNECT ^B¥r^C"
  178.   ifOriginate 36
  179.   QueueInput "¥r^CRING¥r^C"
  180. @Label 36
  181.   HsReset 0,1,0,0,0,1
  182.   Attach "Data" (DTR,Escape,Break)
  183.  
  184. !
  185. ! Fax connection has been established (we read "+FCON")
  186. ! Put the +FCON back to the buffer,
  187. ! if it was an incoming call, put the "RING" before the "+FCON"
  188. ! Attach the "Fax" subPort
  189. !
  190. @Label 40
  191.   QueueInput "¥r¥n+FCON"
  192.   ifOriginate 41
  193.   SetSpeed 19200
  194.   QueueInput "¥r¥nRING¥r¥n"
  195. @Label 41
  196.   IfStr 2 42 "0"
  197.   IfStr 2 42 "3"
  198.   IfStr 2 42 "4"
  199.   Attach "Fax" (DTR,IdleLimit=30)
  200. @Label 42
  201.   Attach "Fax" (DTR,Reset,IdleLimit=30)
  202.  
  203. ! ------------------------------------------
  204. ! Originating a call through the "ARA" subport
  205. ! ------------------------------------------
  206. @ORIGINATE "ARA"
  207.   SerReset Val("^6"),0,8,1
  208.   Jsr 80
  209. !
  210. ! Set the common options
  211.   Jsr 70
  212.   Jsr 60
  213. !
  214. ! Set the communication options:
  215. ! ・ Normal Connection
  216. ! ・ HW flow control
  217. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  218. !
  219.   GetOption A "HWHS" 6
  220.   GetOption B "^3" 6
  221.   GetOption C "LNRS" 6
  222.   Write "AT^A^B^C¥r"
  223.   Jsr 100
  224. !
  225. ! dial the number
  226.   Write "ATD^1¥r"
  227. !
  228. ! Wait for a modem response
  229.   Jsr 90
  230.   IfStr D 30 "DATA"
  231.   Write "¥r"
  232.   Exit -6019
  233.  
  234. ! ------------------------------------------
  235. ! Originating a call through the "DATA" subport
  236. ! ------------------------------------------
  237. @ORIGINATE "Data" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  238.   SerReset Val("^6"),0,8,1
  239.   Jsr 80
  240. !
  241. ! Set the common options
  242.   Jsr 70
  243. !
  244. ! Set the communication options:
  245. ! ・ Normal Connection
  246. ! ・ HW flow control
  247. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  248. !
  249.   GetOption A "HWHS" 6
  250.   GetOption B "^3" 6
  251.   GetOption C "LNRS" 6
  252.   Write "AT^A^B^C¥r"
  253.   Jsr 100
  254. !
  255. ! dial the number
  256.   Write "ATD^1¥r"
  257.   HsReset *
  258. !
  259. ! Wait for a modem response
  260.   Jsr 90
  261.   IfStr D 35 "DATA"
  262.   Write "¥r"
  263.   Exit -6019
  264.  
  265. ! ------------------------------------------
  266. ! Originating a call through the "Fax" subPort
  267. ! ------------------------------------------
  268. @ORIGINATE "Fax" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  269. !
  270. ! Set the "Fax" speed
  271. !
  272.   SerReset 19200,0,8,1
  273.   Jsr 80
  274. !
  275. ! Set the common options
  276. !
  277.   Jsr 70
  278. !
  279. ! Now emit all commands that the application has sent to that port,
  280. ! except "V" and "+FCLASS"
  281. !
  282.   EmitClear "V","+FCLASS"
  283.   Jsr 60
  284.   Write "AT+FCLASS=2¥r"
  285.   Jsr 100
  286. !
  287. ! setting the handshaking mode for faxing
  288.   ifStr 2 50 "3"
  289.   ifStr 2 51 "4"
  290.   HsReset *
  291.   Jump 53
  292. @Label 50
  293.   HSReset 1,0,17,19,1,0
  294.   GetOption A "SWHS" 6
  295.   Jump 52
  296. @Label 51
  297.   HSReset 0,1,0,0,0,0
  298.   GetOption A "HWHS" 6
  299. @Label 52
  300.   Write "AT^A¥r"
  301.   Jsr 100
  302. @Label 53
  303. !
  304. ! dialing the number
  305.   Write "ATD^1¥r"
  306.   Jsr 90
  307.   IfStr D 40 "FAX"
  308.   Write "¥r"
  309.   Exit -6019
  310. !
  311. ! This section emits all modem commands sent from the client application
  312. ! For each set of commands the "OK" answer is awaited
  313. ! For 4-Sight "OK" and/or "ERROR" is OK
  314. !
  315. @Label 60
  316.   EmitStart
  317. @Label 61
  318.   EmitCommand 62
  319.   ifStr 2 63 "1"
  320.   Jsr 100
  321.   Jump 61
  322. @Label 62
  323.   return
  324. @Label 63
  325.   Jsr 120
  326.   Jump 61
  327. !
  328. ! This section initiates the modem before ANSWER and ORIGINATEs:
  329. ! reset on Dtr drop + DCD valid
  330. ! Verbal responses mode, no echo 
  331. !
  332. @Label 70
  333.   Write "AT^4&C1V1E0¥r"
  334.   Jsr 100
  335.   return 
  336.  
  337. !
  338. ! This section syncronize the modem after the serial port speed switching
  339. !
  340. @Label 80
  341.   ChrDelay 1
  342.   Write "AT¥r"
  343.   ChrDelay 0
  344.   Jsr 100
  345.   return
  346. !
  347. ! Error codes
  348. @Label 81
  349.   exit -6020
  350. @Label 82
  351.   exit -6022
  352. @Label 83
  353.   exit -6021
  354. @Label 84
  355.   exit -6023
  356.   
  357. !
  358. ! This subroutine waits for the modem response
  359. ! On exit, ^D contains the result code: "FAX" or "DATA"
  360. ! ^A contains the protocol used
  361. ! ^B contains the carrier speed
  362. ! If modem reports an error, the scripts exits with an error code
  363. !
  364. @Label 89
  365.   Note "Ringノ"
  366.   Jump 91
  367.  
  368. @Label 90
  369.   SetVar A "NONE"
  370.   SetVar B ""
  371.   MatchClr
  372.   Matchstr 1 92 "CARRIER ^$¥r¥n"
  373.   Matchstr 2 93 "PROTOCOL: ^$¥r¥n"
  374.   Matchstr 3 94 "+FCON"
  375.  
  376.   Matchstr 4 95 "CONNECT ^$/"
  377.   Matchstr 5 97 "CONNECT ^$¥r¥n"
  378.   Matchstr 6 89 "RING¥r¥n"
  379.   Matchstr 10 82 "BUSY¥r¥n"
  380.   MatchStr 11 83 "NO CARRIER¥r¥n"
  381.   MatchStr 12 84 "NO ANSWER¥r¥n"
  382.   MatchStr 13 81 "NO DIALTONE¥r¥n"
  383. @Label 91
  384.   Matchread 1200
  385.   SetVar D "NONE"
  386.   return
  387.  
  388. @Label 92
  389.   SetVar B "^$"
  390.   Jump 91
  391. @Label 93
  392.   SetVar A "^$"
  393.   Jump 91
  394. !
  395. ! Fax connection was established
  396. !
  397. @Label 94
  398.   SetVar D "FAX"
  399.   return
  400.  
  401. ! CONNECT xxxx/XXXX was detected
  402. @Label 95
  403.   Jsr 98
  404.   MatchClr
  405.   MatchStr 1 96 "^$¥r¥n"
  406.   MatchRead 10
  407. @Label 96
  408.   SetVar A "^$"
  409.   SetVar D "DATA"
  410.   return
  411.  
  412. ! CONNECT xxx was detected
  413. @Label 97
  414.   Jsr 98
  415.   SetVar D "DATA"
  416.   return
  417.  
  418. @Label 98
  419.   ifStr B 99 ""
  420.   return
  421. @Label 99
  422.   SetVar B "^$"
  423.   return 
  424. !
  425. ! Processing the AT command:
  426. ! OK -> proceed
  427. ! ERROR or TimeOut ->exit -6019
  428. ! It can be called AFTER the "Write" command, since LineShare buffers input
  429. !
  430. @Label 100
  431.   MatchClr
  432.   MatchStr 1 102 "OK¥r¥n"
  433.   MatchStr 2 101 "ERROR¥r¥n"
  434.   MatchRead 20
  435. @Label 101
  436.   Exit -6019
  437. @Label 102
  438.   return
  439.   
  440. !
  441. ! Call this subr if you don't care about your commands
  442. ! (4-Sight sometimes do that)
  443. !
  444. @Label 120
  445.   MatchClr
  446.   MatchStr 1 121 "OK¥r¥n"
  447.   MatchStr 2 121 "ERROR¥r¥n"
  448.   MatchRead 20
  449.   Exit -6019
  450. @Label 121
  451.   return
  452.   
  453.